﻿using Microsoft.AspNetCore.Mvc;
using MinimalistFoodStreet.BackEnd.Infrastructure.Attributes;
using MinimalistFoodStreet.BackEnd.Infrastructure.Dtos.Request.Functions;
using MinimalistFoodStreet.BackEnd.Server.IServer.Tables;
using MinimalistFoodStreet.BackEnd.Server.Server.Tables;

namespace MinimalistFoodStreet.BackEnd.Api.Api.Controllers.Tables
{
    [CheckLogin(new CheckLoginRoles[] {CheckLoginRoles.business})]
    public class CollectionsController:BaseController
    {
        private readonly ICollectionsServer _collectionsServer;

        public CollectionsController(ICollectionsServer collectionsServer)
        {
            _collectionsServer = collectionsServer;
        }
        /// <summary>
        /// 收藏
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Collection(CollectionDto dto) {
            return Send(await _collectionsServer.Collection(dto,_business.BId));
        }
        /// <summary>
        /// 取消收藏
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> CancelCollection(CancelCollectionDto dto) {
            return Send(await _collectionsServer.CancelCollection(dto,_business.BId));
        }
        /// <summary>
        /// 获取收藏分页
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Pagination(int page, int limit) {
            return Send(await _collectionsServer.Pagination(page,limit,_business.BId));
        }
    }
}
